﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Aspfm.Main.Dynamic
{
    public class TestDynamic
    {
        public void Test()
        {
            dynamic theObj = new DynObj();

            theObj.SetPropertyValue("aa","aa");
            string str = theObj.aa;

            theObj.aaa = "this is a test";//动态属性
            //动态方法，这里不能没法定义参数，调用的时候可以是任意多参数，具体参数类型和含义就只能自己去小心处理了.
            theObj.show = DelegateObj.Function((s, pms) =>
            {
                if (pms != null && pms.Length > 0)
                {
                    //MessageBox.Show(pms[0].ToString() + ":" + s.aaa);
                }
                else
                {
                    //MessageBox.Show(s.aaa);
                }
                return null;
            });
            theObj.show("hello");

            dynamic dynobj = Test1(theObj);
            string bb = dynobj.bb;
            string cc = dynobj.cc;
        }

        public dynamic Test1(dynamic dynobj)
        {
            dynobj.bb = "bb";
            return dynobj;
        }
    }
}
